const app = getApp();
import util from "../../../../../utils/util";
import Dialog from "../../../../../dist/dialog/dialog";
let tips_list = [];
Page({

  /**
   * 页面的初始数据
   */
  data: {
    timer: '',
    videoPath:"",
    strShow:false,
    show_skill_flag:false,
    apply_for_type: 1, //1-技能师傅申请、2-技能师傅详情、3-区域技能师傅申请、4-区域技能师傅查看

    addressShow: false,
    streetShow: false,
    id_card_taill: [], //身份证反面
    id_card_front: [], //身份证正面
    promulgator_form: {
      name: "",
      mobile: "",
      age: "",
      address: null,
      card_tail: "",
      card_front: ""
    },

    address_form: {
      province: "",
      city: "",
      district: "",
      street: "",
      address: ""
    },
    districtVal: [], //街道数据

    province_id: "",
    city_id: "",
    district_id: "",
    street_id: "",


    short_video: [],
    photo: [],
    skill_certificate: [],

    openDateLw: false,
    selectAddressData: [],
    isShowStreet: false,
    pickerValue: [0, 0, 0],
    provinceData: [],
    cityData: [],
    districtData: [],
    point:{},
    tips_list:[],


    form: {
      province: "",
      city: "",
      district: "",
      streetName: "",
      locationTitle: "",
    },
    member_id:"",

    duration: 0, //视频时长
    limit: 60, //视频限制时长
    realVideo: "",
    uploadIng: false, //正在上传中
    videoUrl: "",

    health_certificate: [],
    shifu_image: [],
    capability_certificate: [],
    id_card_reverse: [],
    id_card_front: [],
    realname: "",
    mobile: "",
    age: "",
    radio: "",
    native_place: "",
    nation: "",
    education: "",
    stature: "",
    weight: "",
    introduce: "",



    id_card_front_img: "",
    id_card_reverse_img: "",
    capability_certificate_img: "",
    health_certificate_img: "",
    shifu_image_img: "",

    all_serve_columns: [],
    areaShow:false,
    areaList:{},
    stree_columns:[],
    apply_status:null,//申请状态
    can_apply:0,

    uid:"",
    show_popup:false,
    reason:"",
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // apply_type：1-申请、2-详情、3-区域申请 4-区域详情
    
    this._initAddressInfo();
    let apply_for_type = options.apply_type || '';
    this.setData({
      apply_for_type
    })
    if(options.uid){
      this.setData({uid:options.uid,member_id:options.uid});
      this.get_area_info();
    }
    if (apply_for_type == 2 || apply_for_type == 4) {
      // wx.setNavigationBarTitle({
      //   title: '技能师傅主页',
      // })
      if(apply_for_type == 2){
        this.setData({isShowStreet:true})
        this.get_detail();
      }
    }
    if (apply_for_type == 1 || apply_for_type == 3) {
      if(apply_for_type==1){
        //加载地址数据初始化
        this.getValidate();
      }
      // this.getMyLoaction()
    }
    if (apply_for_type == 3) { //区域添加师傅
      wx.setNavigationBarTitle({
        title: '添加技能师傅',
      })
      this.get_server_station();
      this.setData({
        can_apply:99,
        apply_status:1
      })
    }
  },
  gotoRecord(){
    wx.navigateTo({
      url: '/packageJ/anytime_service/my/record/record?name=skill_master',
    })
  },
  
  scrolltolower(){
    this.setData({tips_list: this.data.tips_list.concat(tips_list.slice(0 , this.data.tips_list.length + 10))})
  },
  getMyLoaction(){
    var info = wx.getStorageSync('applyaddresspoint') || wx.getStorageSync('address-point');
    this.setData({
      "form.locationTitle": info.address,
      point: info.point
    })
  },
  focus_handle(){
    this.setData({show_skill_flag:true})
  },
  onClick(e){
    this.setData({radio:e.currentTarget.dataset.item})
  },
  sex_handle(){
    this.setData({show_popup:false});
  },
  get_area_info(){
    app._getNetWork({
      url:app.getNetAddresss("plugin.be-within-call.frontend.area-manage.shifu-info"),
      data:{
        uid:this.data.uid
      },
      success:resdata=>{
        let {result,data,msg} = resdata.data;
        if(result){
          this.setData({
              apply_status:data.apply_status,
              reason:data.reason,
              realname:data.realname,
              mobile:data.mobile,
              member_realname:data.has_one_member.nickname,
              radio:data.detail_info.sex == '男' ? '1':'2',
              age:data.detail_info.age,
              addressName:`${data.province_name} ${data.city_name} ${data.district_name}`,
              "form.streetName":data.street_name,
              native_place:data.detail_info.native_place,
              nation:data.detail_info.nation,
              education:data.detail_info.education,
              stature:data.detail_info.stature,
              weight:data.detail_info.weight,
              introduce:data.detail_info.introduce,
              id_card_front_img: data.annex_file.id_card_front,
              id_card_reverse_img: data.annex_file.id_card_reverse,
              capability_certificate_img: data.annex_file.capability_certificate,
              health_certificate_img:data.annex_file.health_certificate? data.annex_file.health_certificate:'',
              shifu_image_img: data.annex_file.shifu_image,
              videoUrl: data.annex_file.shifu_video_url,
              videoPath:data.annex_file.shifu_video,
              skill_certificate:data.annex_file.capability_certificate_url?[{url:data.annex_file.capability_certificate_url}]:[],
              photo:[{url:data.personal_pic}],
              id_card_front:[{url:data.annex_file.id_card_reverse_url}],
              id_card_taill:[{url:data.annex_file.id_card_front_url}],
              health_certificate:data.annex_file.health_certificate_url?[{url:data.annex_file.health_certificate_url}]:[],
              province_id:data.province_id,
              city_id:data.city_id,
              district_id:data.district_id,
              street_id:data.street_id,
              "point.lat":data.latitude,
              "point.lng":data.longitude,
              isShowStreet:true,
          })
          this._setOrderLocation({
            lat: data.latitude,
            lng: data.longitude
          })
        }else{
          app.tips(msg);
        }
      }
    })
  },
  sex_onChange(e){
    console.log(e,"e====");
  },
  area_cancel(){
    this.setData({areaShow:false})
  },
  stree_confirm(e){
    let stree_name = e.detail.value;
    let result = this.data.all_serve_columns.filter(item => {
      if (item.province_id == this.data.province_id && item.city_id == this.data.city_id && item.district_id == this.data.district_id) {
        return item;
      }
    })
    result.forEach(item => {
      if (item.street_name == stree_name) {
        this.data.street_id = item.street_id;
      }
    })
    this.setData({
      strShow:false,
      "form.streetName":stree_name
    })
  },
  stree_cancel(){
    this.setData({strShow:false})
  },
  area_confirm(e){
    console.log(e);
    let columnsNum = e.detail.values;
    let  addressName = `${columnsNum[0].name} ${columnsNum[1].name} ${columnsNum[2].name}`;
 
    this.data.province_id = columnsNum[0].code;
    this.data.city_id = columnsNum[1].code;
    this.data.district_id = columnsNum[2].code;
    let _arr = this.data.all_serve_columns.filter(item => {
      if (item.province_id == columnsNum[0].code && item.city_id == columnsNum[1].code && item.district_id == columnsNum[2].code) {
        return item;
      }
    })
    let  stree_columns = [];
    _arr.forEach(item => {
     stree_columns.push(item.street_name);
    });
    this.setData({
      isShowStreet:true,
      addressName,stree_columns,strShow:true,areaShow:false,
    })
  },
  openAreabtn(e){
    let v = e.currentTarget.dataset.v;
    if(v=="1"){
      this.setData({areaShow:true})
    }else{
      this.setData({
        strShow:true
      })
    }
  },
  getValidate(){
    app._getNetWork({
      url:app.getNetAddresss("plugin.be-within-call.frontend.role-apply.detail"),
      data:{
        role:2,
        validate_page:1
      },
      success:resdata=>{
        let {result,msg,data}=resdata.data;
        if(result){ 
          if (data.apply_status == 0 || data.can_apply == 99) {
            this.setData({
              can_apply:data.can_apply,
              apply_status:data.apply_status
            })
          }
          if(data.apply_status==-1){
            this.setData({
              "point.lat":data.latitude,
              "point.lng":data.longitude,
              isShowStreet:true,
              apply_status:data.apply_status,
              reason:data.reason,
              realname: data.realname,
              radio: data.detail_info && data.detail_info.sex == '男' ? '1' : '2',
              mobile: data.mobile,
              age: data.detail_info.age,
              "form.streetName": data.street_name,
              addressName: `${data.province_name} ${data.city_name} ${data.district_name}`,
              native_place: data.detail_info.native_place,
              nation: data.detail_info.nation,
              education: data.detail_info.education,
              stature: data.detail_info.stature,
              weight: data.detail_info.weight,
              introduce: data.detail_info.introduce,
              id_card_front_img: data.annex_file.id_card_front,
              id_card_reverse_img: data.annex_file.id_card_reverse,
              capability_certificate_img: data.annex_file.capability_certificate,
              health_certificate_img: data.annex_file.health_certificate,
              shifu_image_img: data.annex_file.shifu_image,
              videoUrl: data.annex_file.shifu_video_url,
              videoPath:data.annex_file.shifu_video,
              skill_certificate:data.annex_file.capability_certificate_url?[{url:data.annex_file.capability_certificate_url}]:[],
              photo:[{url:data.personal_pic}],
              id_card_front:[{url:data.annex_file.id_card_reverse_url}],
              id_card_taill:[{url:data.annex_file.id_card_front_url}],
              health_certificate:data.annex_file.health_certificate_url?[{url:data.annex_file.health_certificate_url}]:[],
              province_id:data.province_id,
              city_id:data.city_id,
              district_id:data.district_id,
              street_id:data.street_id,
            })
            this._setOrderLocation({
              lat: data.latitude,
              lng: data.longitude
            })
          }
          if(data.latitude==''&&data.longitude==''){
            this.getMyLoaction();
          }
        }else{
          app.tips(msg);
        }
      }
    })
  },
  submit_anew(){
    Dialog.confirm({
      title:"提示",
      selector:'#myDialog',
      message: '是否确定重新发布?',
    })
      .then(() => {
        this.submit();
      })
      .catch(() => {
        // on cancel
      });
  },
  get_server_station() {
    app._getNetWork({
      url: app.getNetAddresss('plugin.be-within-call.frontend.area-manage.limit'),
      success: resdata => {
        let {
          result,
          data,
          msg
        } = resdata.data;
        if (result) {
          this.setData({
            all_serve_columns: data.agent_address
          })
          this.formatdata(data.agent_address);
        } else {
          app.tips(msg);
        }
      }
    })
  },
  formatdata(data) {
    let obj1 = {},
      obj2 = {},
      obj3 = {};
      console.log(data,"data==");
    data.forEach(item => {

      if (!obj1[item.province_id]) {
        obj1[item.province_id] = item.province_name;
      }
      if (!obj2[item.city_id]) {
        obj2[item.city_id] = item.city_name;
      }
      if (!obj3[item.district_id]) {
        obj3[item.district_id] = item.district_name;
      }
    });
    let areaList = {
      province_list: obj1,
      city_list: obj2,
      county_list: obj3,
    }
    console.log(areaList,"areaList");
    this.setData({
      areaList
    })

  },
  get_detail() {
    this.setData({apply_for_type:"1",can_apply:99})
    app._getNetWork({
      url: app.getNetAddresss('plugin.be-within-call.frontend.role-apply.detail'),
      data: {
        role: 2,
      },
      success: resdata => {
        let {
          result,
          data,
          msg
        } = resdata.data;
        if (result) {
            this.setData({
              "point.lat":data.latitude,
              "point.lng":data.longitude,
              apply_status:data.apply_status,
              reason:data.reason,
              realname: data.realname,
              radio: data.detail_info && data.detail_info.sex == '男' ? '1' : '2',
              mobile: data.mobile,
              age: data.detail_info.age,
              "form.streetName": data.street_name,
              addressName: `${data.province_name} ${data.city_name} ${data.district_name}`,
              native_place: data.detail_info.native_place,
              nation: data.detail_info.nation,
              education: data.detail_info.education,
              stature: data.detail_info.stature,
              weight: data.detail_info.weight,
              introduce: data.detail_info.introduce,
              id_card_front_img: data.annex_file.id_card_front,
              id_card_reverse_img: data.annex_file.id_card_reverse,
              capability_certificate_img: data.annex_file.capability_certificate,
              health_certificate_img: data.annex_file.health_certificate,
              shifu_image_img: data.annex_file.shifu_image,
              videoUrl: data.annex_file.shifu_video_url,
              videoPath:data.annex_file.shifu_video,
              skill_certificate:data.annex_file.capability_certificate_url?[{url:data.annex_file.capability_certificate_url}]:[],
              photo:[{url:data.personal_pic}],
              id_card_front:[{url:data.annex_file.id_card_reverse_url}],
              id_card_taill:[{url:data.annex_file.id_card_front_url}],
              health_certificate:data.annex_file.health_certificate_url?[{url:data.annex_file.health_certificate_url}]:[],
              province_id:data.province_id,
              city_id:data.city_id,
              district_id:data.district_id,
              street_id:data.street_id,
            })
            this._setOrderLocation({
              lat: data.latitude,
              lng: data.longitude
            })

        }else{
          app.tips(msg);
        }
      }
    })
  },

  //根据经纬度转换具体地址名称
  _setOrderLocation(e) {
    app.getReverseGeocoder(e.lat, e.lng).then(res => {
      console.log("userLocationFlag", res);
      this.setData({
        "form.locationTitle": `${res.address_component.province}${res.address_component.city}${res.formatted_addresses.recommend}`
      })
    }).catch(function (err) {
      console.log(err);
    });
  },
  closePop() {
    this.setData({
      genderShow: false
    })
  },
  toGeolocation() {
    wx.navigateTo({
      url: "/packageC/o2o/o2oLocation_loc/o2oLocation_loc?tag=storeApply",
    });
  },

  selectSex() {
    this.setData({
      show_popup: true
    })
  },
  //选择街道
  streetConfirm(e) {
    let strname = e.target.dataset.strname;
    let street_id = e.target.dataset.id;
    this.setData({
      "form.streetName": strname,
      streetShow: false,
      street_id
    });
  },
  //打开地址选择器
  openDateLwtbtn: function () {
    this.setData({
      openDateLw: true,
    });
  },
  streetChoose() {
    this.setData({
      streetShow: true,
    });
  },

  // 收货地址滚动事件
  bindChange: function (e) {
    var val = e.detail.value;
    if (this.data.pickerValue[0] != val[0]) {
      val[1] = 0;
      val[2] = 0;
    }
    if (this.data.pickerValue[1] != val[1]) {
      val[2] = 0;
    }
    this.setData({
      "pickerValue[0]": val[0],
      "pickerValue[1]": val[1],
      "pickerValue[2]": val[2],
    });
    this._initAddressInfo();
  },

  //地址选择器数据初始化
  _initAddressInfo: function () {
    var that = this;
    var _keyName = "provinceData";
    wx.getStorage({
      key: _keyName,
      success: function (res) {
        that._getProvinceData();
      },
      fail: function (res) {
        app._getNetWork({
          url: app.getNetAddresss("member.member-address.address"),
          success: function (res) {
            var response = res.data;
            var province = response.data.province;
            var city = response.data.city;
            var district = response.data.district;
            wx.setStorage({
              key: "provinceData",
              data: province,
            });
            wx.setStorage({
              key: "cityData",
              data: city,
            });
            wx.setStorage({
              key: "districtData",
              data: district,
            });
            that._initAddressInfo();
          },
          fail: function (res) {},
          state: true,
        });
      },
    });
  },

  // 读取省key
  _getProvinceData: function () {
    var that = this;
    var _keyName = "provinceData";
    wx.getStorage({
      key: _keyName,
      success: function (res) {
        that.setData({
          provinceData: res.data,
        });
        that.setData({
          "selectAddressData[0].name": res.data[that.data.pickerValue[0]].areaname,
          "selectAddressData[0].id": res.data[that.data.pickerValue[0]].id,
          "selectAddressData[0].index": that.data.pickerValue[0],
        });
        that._getCityData();
      },
    });
  },
  // 读取城市key，筛选城市data
  _getCityData: function () {
    var _data = this.data.selectAddressData[0];
    var that = this;
    var _keyName = "cityData";
    wx.getStorage({
      key: _keyName,
      success: function (res) {
        var _json = [];
        for (var i = 0; i < res.data.length; i++) {
          if (res.data[i].parentid == _data.id) {
            _json.push(res.data[i]);
          }
        }
        that.setData({
          cityData: _json,
        });
        that.setData({
          "selectAddressData[1].name": _json[that.data.pickerValue[1]].areaname,
          "selectAddressData[1].id": _json[that.data.pickerValue[1]].id,
          "selectAddressData[1].index": that.data.pickerValue[1],
        });
        that._getDistrictData();
      },
    });
  },
  // 读取地区key，筛选地区data
  _getDistrictData: function () {
    var _data = this.data.selectAddressData[1];
    var that = this;
    var _keyName = "districtData";
    wx.getStorage({
      key: _keyName,
      success: function (res) {
        var _json = [];
        for (var i = 0; i < res.data.length; i++) {
          if (res.data[i].parentid == _data.id) {
            _json.push(res.data[i]);
          }
        }
        that.setData({
          districtData: _json,
        });
        that.setData({
          "selectAddressData[2].name": _json[that.data.pickerValue[2]].areaname,
          "selectAddressData[2].id": _json[that.data.pickerValue[2]].id,
          "selectAddressData[2].index": that.data.pickerValue[2],
        });
      },
    });
  },
  _closeDateLw: function () {
    this.setData({
      openDateLw: false,
    });
  },
  _okAddress: function () {
    let seleData = this.data.selectAddressData;
    this.setData({
      district_id:seleData[2].id,
      city_id:seleData[1].id,
      province_id:seleData[0].id,
      "form.streetName": "",
      districtVal: "",
      addressName: seleData[0].name + " " + seleData[1].name + " " + seleData[2].name,
      "form.province": seleData[0].name,
      "form.city": seleData[1].name,
      "form.district": seleData[2].name,
    });
   this._getStreet(seleData[2].id);
    this._closeDateLw();
  },

  //获取街道
  _getStreet(param) {
    var that = this;
    let urlStr = app.getNetAddresss("member.memberAddress.street");
    urlStr += "&district_id=" + param;
    app._getNetWork({
      url: urlStr,
      success: function (resdata) {
        var res = resdata.data;
        if (res.result == 1 && !app._isTextEmpty(res.data)) {
          if (!app._isTextEmpty(res.data) && res.data.length > 0) {
            that.setData({
              districtVal: res.data,
              isShowStreet: true,
            });
          } else {
            that.setData({
              isShowStreet: false,
            });
          }
        } else {
          that.setData({
            isShowStreet: false,
          });
        }
      },
      fail: function (res) {
        console.log(res);
      },
    });
  },

  submit() {
    let json = {
      identity:2,
      realname: this.data.realname,
      mobile: this.data.mobile,
      province_id: this.data.province_id,
      city_id: this.data.city_id,
      district_id: this.data.district_id,
      street_id: this.data.street_id,
      longitude: this.data.point.lng,
      latitude: this.data.point.lat,
      detail_info:{
        native_place:this.data.native_place,
        nation:this.data.nation,
        education:this.data.education,
        stature:this.data.stature,
        weight:this.data.weight,
        introduce:this.data.introduce,
        age:this.data.age,
      },
      annex_file:{
        id_card_reverse:this.data.id_card_reverse_img,
        id_card_front:this.data.id_card_front_img,
        shifu_image:this.data.shifu_image_img,
      }
    }

    if(this.data.health_certificate_img){
      json.annex_file.health_certificate = this.data.health_certificate_img;
    }

    if(this.data.capability_certificate_img){
      json.annex_file.capability_certificate = this.data.capability_certificate_img;
    }
    if(this.data.radio){
      json.detail_info.sex = this.data.radio == 1 ? '男' : '女';
    }
    if(this.data.videoPath){
      json.annex_file.shifu_video=this.data.videoPath;
    }
    let urlStr = "plugin.be-within-call.frontend.role-apply.index";

    if(this.data.uid || this.data.apply_for_type == '3'){
      urlStr = 'plugin.be-within-call.frontend.area-manage.add-shi-fu';
      json.member_id = this.data.member_id;
      delete json.identity
    }
    app._postNetWork({
      url:app.getNetAddresss(urlStr),
      data:{
        data:json
      },
      success:resdata=>{
        let {result,msg} = resdata.data;
        app.tips(msg);
        if(result){
          setTimeout(() => {
            if(this.data.apply_for_type == 1){
              wx.redirectTo({
                url: '/packageJ/anytime_service/my/index/index',
              })
            }else{
              wx.redirectTo({
                url: '/packageJ/anytime_service/my/area_manage/area_manage',
              })
            }
          }, 300);
        }
      }
    })
  },
  removeImg() {
    this.setData({
      videoUrl: null
    })
  },
  onReadVideo() {
    wx.chooseMedia({
      count: 1,
      mediaType: ['video'],
      sourceType: ['album', 'camera'],
      maxDuration: 60,
      success: res => {
        this.getDuration(res.tempFiles[0]);
      }
    })
  },
  getDuration(_Files) {
    let basic_info = wx.getStorageSync("yz_basic_info");
    let {
      upload_max_file_size
    } = basic_info;
    let _max = 100; //php配置最大文件上传大小
    if (upload_max_file_size) _max = upload_max_file_size / 1024 / 1024;
    if (_Files.size / 1024 / 1024 > _max) {
      app.tips(`视频大小超出${_max}M，请压缩后上传！`);
      this.resetVideo();
      return;
    }
    //获取视频或者音频时长
    this.data.duration = _Files.duration;
    if (this.data.duration < 1) {
      this.resetVideo();
      app.tips("视频时长太短了！！");
      return;
    }
    if (this.data.limit && this.data.duration > Number(this.data.limit) + 1) {
      this.resetVideo();
      app.tips(`视频时长不能超过${this.data.limit}秒`);
      return;
    }

    this.setSrcAndCaptureImage(_Files.tempFilePath);
    this.setData({
      videoUrl: _Files.tempFilePath
    });
  },

  setSrcAndCaptureImage(videoData) {
    this.data.realVideo = videoData;
    if (this.data.realVideo) {
      this.setData({
        videoUrl: null
      });
    }
    this.uploadAudioM(); //上传视频 --------------
  },

  uploadAudioM() {
    let that = this;
    //视频上传
    that.setData({
      uploadIng: true
    });
    let urlStr = app.getNetAddresss("plugin.video-share.frontend.upload.uploadAudio");
    wx.uploadFile({
      url: urlStr, //仅为示例，非真实的接口地址
      filePath: this.data.realVideo,
      name: 'file',
      formData: {},
      header: {
        "Content-Type": "application/json",
        Accept: "application/json",
      },
      success(res) {
        var resData = JSON.parse(res.data);
        if (resData.result == 1) {
          that.setData({
            uploadIng: false,
            videoPath: resData.data.audio,
          });
          
        } else {
          that.setData({
            videoUrl: null,
            duration: 0,
            limit: '',
            uploadIng: false,
          });
          wx.showToast({
            title: resData.msg,
            icon: 'none',
            duration: 2500
          });
        }
      }
    });
  },
  resetVideo() {
    // 重置视频地址
    this.setData({
      videoUrl: null
    });
  },
  delete(e) {
    let field = e.currentTarget.dataset.field;
    this.setData({
      [field]: []
    })
    if(field=='skill_certificate'){
      this.setData({capability_certificate_img:""});
    }else if(field == 'id_card_front'){
      this.setData({id_card_reverse_img:""});
    }else if(field == 'id_card_taill'){
      this.setData({id_card_front_img:""});
    }else if(field == 'health_certificate'){
      this.setData({health_certificate_img:""})
    }else if(field == 'photo'){
      this.setData({shifu_image_img:""})
    }
  }, 
  onInput(e) {
    let field = e.currentTarget.dataset.field;
    let value = e.detail;
    this.setData({
      [field]: value
    })
  },
  choose_handle(e){
    console.log(e,"===");
    let data = e.currentTarget.dataset.item;
    this.setData({
      tips_list:[],
      show_skill_flag:false,
      member_realname: data.nickname,
      member_id:data.uid
    })
  },
  MemberList(){

    app._getNetWork({
      url:app.getNetAddresss("plugin.be-within-call.frontend.area-manage.search-user"),
      data:{kwd:this.data.member_realname},
      success:resdata=>{
        let {result,data} = resdata.data;
        if(result){
          if (data && data.length !== 0) {
            tips_list = data;
            this.setData({tips_list: data.splice(0,10),show_skill_flag:true})
          }
        }
      }
    })
  },
  input_handle(e) {
    console.log(e,"e====");
    this.setData({member_realname:e.detail})
    if (!this.data.show_skill_flag) {
      return false;
    }
    if (this.timer) clearTimeout(this.timer);
    this.timer = setTimeout(() => {
      util.debounce(this.MemberList());
    }, 500);
  
  },
  afterRead(event) {
    wx.showLoading({
      title: '上传中'
    })
    const {
      file
    } = event.detail;
    let {
      field
    } = event.currentTarget.dataset;
    let urlStr = app.getNetAddresss("upload.uploadPic");
    wx.uploadFile({
      url: urlStr,
      filePath: file.url,
      name: 'file',
      success: (resdata) => {
        app.tips("上传成功")
        let res = JSON.parse(resdata.data);
        let arr = []
        arr.push({
          ...file,
          url: res.data.img_url,
          status: "done",
          message: '上传完成'
        });
        this.setData({
          [field]: arr
        });
        let img = res.data.img;
        let key = ""
        if(field == 'photo'){
          key = 'shifu_image_img';
        }else if(field == 'skill_certificate'){
          key = 'capability_certificate_img';
        }else if(field == 'id_card_front'){
          key = 'id_card_reverse_img';
        }else if(field == 'id_card_taill'){
          key = 'id_card_front_img'
        }else if(field == 'health_certificate'){
          key = 'health_certificate_img';
        }
        this.setData({
          [key]:img
        })
        wx.hideLoading();
      },
      fail(err) {
        app.tips("上传失败")
        console.log(err);
        wx.hideLoading();
      }
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    // this.getMyLoaction()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})